package collection.hashmap;


import org.junit.Test;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author : James
 * @Create : 2021-11-01-11:27
 * @Description :
 */
public class Demo01 {

    @Test
    public void capacity() throws Exception {
        Map<String,String> map = new HashMap<>(50);
        map.put("k1","v1");
        Class<? extends Map> mapType = map.getClass();
        Method capacity = mapType.getDeclaredMethod("capacity");
        capacity.setAccessible(true);
        System.out.println("capacity :"+capacity.invoke(map));
        Field size = mapType.getDeclaredField("size");
        size.setAccessible(true);
        System.out.println("size "+size.get(map));
        Field threshold = mapType.getDeclaredField("threshold");
        threshold.setAccessible(true);
        System.out.println("threshold "+threshold.get(map));

    }




}
